<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	
	<div ng-app="app" ng-controller="ctrl">
		<label>Name: <input type="text" ng-model="user.name" /></label><br/>
		<label>Age: <input type="text" ng-model="user.age" /></label><br/>
		Gender: <label><input type="radio" ng-model="user.gender" value="male"/>male</label>
				<label><input type="radio" ng-model="user.gender" value="female" />female</label>
		<br/>
		<button ng-click="reset();">Reset</button>
		<button ng-click="update(user);">Update</button>

		<pre>user = {{user | json}}</pre>
		<pre>leader = {{leader | json}}</pre>
	</div>

	<script type="text/javascript" src="../angular/angular-1.6.5.min.js"></script>
	<script type="text/javascript">
		angular.module('app', [])

		.controller('ctrl', ['$scope', function ($scope) {
			$scope.leader = {};

			//深拷贝
			$scope.reset = function(){
				angular.copy($scope.leader, $scope.user);
			}

			$scope.update = function(user){
				angular.copy(user, $scope.leader);
			}
		}]);

	</script>
</body>
</html>